<template>
    <div>
      <h3>这是登陆接口</h3>
      <p>账号：<input type="text" v-model="username"></p>
      <p>密码：<input type="text" v-model="password"></p>
      <p>
        <button type="submit" @click="submit">点击登陆</button>
      </p>

    </div>
</template>

<script>
    export default {
        data(){
            return{
                username:"",
                password:""
            }
        },
        methods:{
            submit(){
                this.axios.get('http://127.0.0.1:8000/login',{params:{
                        'username':this.username,
                        'password':this.password
                    }}).then(res=>{
                        if (res.data.code == 200){
                            alert(res.data.data);
                            localStorage.setItem('username', this.username)
                        }else {
                            alert(res.data.data)
                        }
                })
            }
        }

    }
</script>

<style scoped>

</style>
